/**
 * DomWon
 * Created with Intellij IDEA.
 * Description:
 * User:WEI
 * Date:2023/3/8
 * Time:7:45
 */
public class TestDemo {
    public static void main(String[] args) {
        int [] array = {95,98,71,64,82,74,61,84};
        double ret = average(array);
        System.out.println("这群学生的平均分是："+String.format("%.2f",ret));
    }

    public static double average (int [] array) {
        double sum = sum(array);
        System.out.println(sum);
        double avg = sum/array.length;
        return avg;
    }

    public static int sum (int [] array) {
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        return sum;
    }

    public static void main4(String[] args) {
        int [] array = {1,2,3,4,5,6,7,8,9};
        int ret =sum(array);
        System.out.println(ret);
    }



    public static void main3(String[] args) {
        int [] array = {11,22,33,44,55,66,77,88,99};
        transform(array);
    }

    public static void transform (int [] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]*2);
        }
    }

    public static void main2(String[] args) {
        int [] array = {12,34,56,78,90};
        printArray(array);
    }

    public static void printArray(int [] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }

    public static void main1(String[] args) {
        int [] array =new int[100];
        for (int i = 0; i < 100; i++) {
            array[i] = i+1;
        }
        for (int x:array) {
            System.out.print(x+" ");
        }
    }
}
